// database unit tool 
const object = {
    login: (ctx, userData) => {
        ctx.session.authorised = true;
        ctx.session.userData = userData;
    },
    logout: (ctx) => {
        ctx.session.authorised = null;
        ctx.session.userData = null;
    },
    getUserSession: (ctx) => {
        // id,user,pass,email,avatarUrl
        return ctx.session.userData;
    },
    getUserId: (ctx) => {
        return ctx.session.userData && ctx.session.userData.id;
    },
    isLogin: (ctx)=>{
        return !!(ctx.session && ctx.session.authorised);
    }
};



module.exports = object;